package com.d3works.apps.production.service;

import com.d3works.apps.base.db.Product;
import com.d3works.apps.base.db.repo.ProductRepository;
import com.d3works.apps.base.db.repo.ProductVariantRepository;
import com.d3works.apps.base.service.app.AppBaseService;
import com.d3works.apps.supplychain.service.ProductVariantServiceSupplyChainImpl;
import com.d3works.inject.Beans;
import com.google.inject.Inject;

public class ProductVariantServiceProductionImpl extends ProductVariantServiceSupplyChainImpl {

  @Inject
  public ProductVariantServiceProductionImpl(
      ProductRepository productRepo, ProductVariantRepository productVariantRepo) {
    super(productRepo, productVariantRepo);
  }

  @Override
  public Product copyAdditionalFields(Product product, Product productModel) {
    product = super.copyAdditionalFields(product, productModel);
    if (Beans.get(AppBaseService.class).isApp("production")) {
      product.setProductStandard(productModel.getProductStandard());
      product.setProductApproval(productModel.getProductApproval());
    }
    return product;
  }
}
